const obj = {
	name: 'zhangsan',
	age: 12
}
function deepCopy(obj) {
	var obj2 = Object.prototype.toString.call(obj) === '[object Array] ' ? [] : {}
	for (var key in obj) {
		// 检测属性是否为对象的自有属性
		if (obj.hasOwnProperty(key)) {
			if (typeof obj[key] === 'object') {
				obj2[key] = deepCopy(obj[key])
			} else {
				obj2[key] = obj[key]
			}
		}
	}
	return obj2
}

var o = deepCopy(obj)
o.name = "lisi"
console.log(obj);
console.log(o) 